//
//  UIBarButtonItem+EXtension.swift
//  Weibo
//
//  Created by 黄健桦 on 2016/9/23.
//  Copyright © 2016年 黄健桦. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    convenience init(title: String = "", imageName: String, target: Any?, action: Selector) {
        let btn = UIButton()
        
        btn.setTitle(title, for: .normal)
        
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        btn.setImage(UIImage(named: imageName), for: .normal)
        
        btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        
        btn.sizeToFit()
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        self.init()
        
        self.customView = btn
        
    }
}
